$(function(){
    var start = new google.maps.LatLng(50.619192,26.250629);
    var mapOptions = {
      zoom: 14,
      center: start,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

    Bus.getForm().submit(Bus.onSubmit);
    $('#form_bus_cancel').click(function(){
        Bus.getForm().hide();
        Bus.resetForm();
    });
    Bus.getForm().hide();
    $('#button_add_bus').click(function(){
        Bus.resetForm();
        Bus.getForm().show();
        $('#bus_delete-element').hide();
    });
    $('#bus_delete').click(function(){
        Bus.remove();
    })
    Bus.reloadList();
    $('#bus_list').click(function(e){
        var target = $(e.target);
        if (target.hasClass('bus-item')) {
            Bus.edit(target.attr('bus_id'));
        }
    });

    $("#tabs").tabs();

    // Stops
    Stop.getForm().hide();
    Stop.getForm().submit(Stop.onSubmit);
    Stop.reloadList();
    $('#stop_cancel').click(Stop.onCancel);
});